﻿Imports System.IO

Public Class Dictionary
    Public dict As List(Of DictObject)
    Dim dictpath As String
    Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        dictpath = Directory.GetCurrentDirectory + "\dict.txt"

        If File.Exists(dictpath) Then
            dict = TextSerializer.DeserializeDict(dictpath)

        Else
            dict = New List(Of DictObject)
        End If

        Me.DictBinding.DataSource = dict
    End Sub

    Private Sub Dictionary_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        TextSerializer.SerializeDict(dictpath, dict)
    End Sub

    Private Sub Dictionary_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyCode = Keys.Escape Then
            Me.Close()
        End If
    End Sub
End Class